var serviceDemand = "DemandServlet";
var serviceLogin = "LoginServlet";
var serviceRecruitment = "RecruitmentServlet";
var serviceFilters = "ViewFiltersServlet";

function ajaxJSONtoGET(params, service) {
	var json = null;
	var oAjax = new Ajax.Request(service, {
		parameters	:	{
			jsonReq	:	params
		},
		method		:	'get',
		asynchronous:	false,
		onComplete	:	function(transport) {
			json = transport.responseText.evalJSON();
		},
		on404		:	function(response) {
			alert("Error 404");
		},
		on403	:	function(response) {
			alert("La sesion ha expirado. Favor de autenticarse");
			redirectLogin();
		},
		
		onFailure	:	function(response) {
			alert("Error Ajax. Status: "+response.status);
		}
	});
	return json;
} 

function ajaxJSONtoPOST(params, service) {
	var json = null;
	var oAjax = new Ajax.Request(service, {
		parameters	:	{
			jsonReq	:	params
		},
		method		:	'post',
		asynchronous:	false,
		onComplete	:	function(transport) {
			json = transport.responseText.evalJSON();
		},
		on404		:	function(response) {
			alert("Error 404");
		},
		on403	:	function(response) {
			alert("La sesion ha expirado. Favor de autenticarse");
			redirectLogin();
		},
		
		onFailure	:	function(response) {
			alert("Error Ajax. Status: "+response.status);
		}
	});
	return json;
} 
/*
function ajaxRequestExport(params, service) {
	var json = null;
	var responseAjax = "testing function";
	var oAjax = new Ajax.Request(service, {
		parameters	 :	{
			jsonReq	:	params
		},
		method		:	'post',
		asynchronous:	false,
		onComplete	:	function(response) {
			var parametros = "width=200,height=50,left=45%,top=50%,toolbar=no,menubar=no,location=no,scrollbars=no";
			window.open('Downloader.jsp',"",parametros);
		},
		on404		:	function(response) {
			alert("Error 404");
		},
		on403	:	function(t) {
			alert("La sesion ha expirado. Favor de autenticarse");
			top.location = "apps/Login.jsp";
		},
		onFailure	:	function(response) {
			alert("Error peticion Ajax");
		}
	});
	
	return responseAjax;
}
*/